/***************************************************************************
 创建者: 华磊
 开始时间: 2020.8.14
 copyright: (C) 华友高科
 修改说明: (每次有修改就添加一条，带有 修改人，修改时间，修改描述)
 example (1) hualei 2020.5.8 类的具体实现代码编写

 ***************************************************************************
 *  @file x.h
 *  功能:
 *
 *                                                                         *
 ***************************************************************************/
#ifndef ROBOTATTRIBUTE_H
#define ROBOTATTRIBUTE_H
#include "qstring.h"
#include "trajectoryudefine.h"
#include "domparser.h"
#include "qdebug.h"
#include "MacroDefine/GeneralDefine.h"
#include "motionmessage.h"

using namespace std;
/**
 * @brief The RobotAttribute class 机器人通用参数读取类
 */
class RobotAttribute:DomParser
{
public:
    RobotAttribute(QString fileNameIn, int robotIdIn, MotionMessage *motionMessageIn);

public:

    int setGravityVector(vector<double> gravityIn);

    int setVehicleTrajectoryControlParameter(struct VehicleTrajectoryControlParameter infoIn,int &returnFlag);
    int setAxisPositionLimit(int axisId,double minPositionIn,double maxPositionIn,double approachDistanceIn,
                             int &returnFlag);
    int setAxisProperty(int axisId, struct AxisProperty_hmi axisPropertyIn);
    int getAxisProperty(int axisId, struct AxisProperty_hmi &axisPropertyOut);

    int getRobotCoordinateConfig(struct RobotCoordinateAxisConfig &coordinateConfigOut);
    int setRobotCoordinateConfig(struct RobotCoordinateAxisConfig coordinateConfigIn);

    int readFile(QString &readComent);
    int checkFile();
    int getRobotAttribute(RobotCommonParameter & roboParameter);
    int getMotionServerModel(QString fileNameIn,MC_MOTION_MODEL& modelOut);
    int getAutoRatio(QString fileNameIn, double& autoRatioOut, double &manualRatioOut, int &recordWeaveOut);
    int writeAutoRatio(QString fileNameIn, double autoRatioIn,double manualRatioIn);

    int getLastFloorInfo(QString fileNameIn,  PathMovingInfo &pathMovingOut,VehiclePosition &positionOut);
    int writeLastFloorInfo(QString fileNameIn, PathMovingInfo pathMovingIn,VehiclePosition positionIn);


    int isUsePositionRegulator();
    int getAutoSaveWaveFlag();

private:

    int readAxisParameter(QVector<bool> &okReturn,QDomNode  tmpNode,JointAttribute &joint);
    void addMsg(int messageLevel, std::string componentName, std::string messageType, int messageCode
                , int _robotId, int parameter1=0,int parameter2=0,QString comment="");

public:
    int robotId;
    int robotType;
    int coordinateSize;//废弃不用
    int jointNum;
    int armControlAxisNumber;
    int externalNum;
    int agvAxisNum;
    int virtualAxisNum;
    double deltaTime;// unit: s
    float t1RatioLimit;
    float arm_CeaseTime;
    float arm_StopTime;
    double arm_warnSpeedRatio;
    double arm_warnSlowRatio;

//    float agv_CeaseTime;
//    float agv_StopTime;
    float targetWaitTime; // unit: s
    float lineMaxSpeed;// unit: mm/s
    float lineMaxAcceleration;// unit: mm/s
    int jointMoveVelocityType;
    float agv_targetWaitTime; // unit: s
    float agv_lineMaxSpeed;// unit: mm/s
    float agv_lineMaxAcceleration;// unit: mm/s
    float agv_rotateMaxSpeed;// unit: mm/s
    float agv_rotateMaxAcceleration;// unit: mm/s
    int agv_jointMoveVelocityType;
    float agv_allowLineOffset;//unit is mm
    float agv_allowAngleOffset;//unit is degree
    float agv_allowLineMovingOffset;//unit is mm
    float agv_allowLineMovingOffset_ratio;
    float agv_allowAngleMovingOffset;//unit is degree
    int isArmMotionOn;
    int isAgvMotionOn;
    double rotate_eqradius;//unit is mm 用于计算ａｇｖ旋转
    float agv_emergencyRotateAcceleration;// unit: mm/s
    float agv_emergencyLineAcceleration;// unit: mm/s
    double allowVelFeedbackBiasRatio;
    int isUsePositionRegulatorStatus;
    int autoSaveWaveFlag;
    QVector<double> gravity;
    bool isCalculateIdealJointTorque;
    int armTpType;
    int maxLineCatshDepth_carvingTp;
    double jogDecartRotateRation;
    double jogDecartLineRatio;

private:
    QString filePath;
    QVector<JointAttribute>  robotJoints;
    MotionMessage *motionMessage;


    //private:
    //    /**
    //     * @brief mcMd5Instance
    //     */
    //    MD5Check *mcMd5Instance;


};

#endif // ROBOTATTRIBUTE_H
